//
//  CyclePictureTCell.swift
//  MikerShoppingApp
//
//  Created by eme on 2016/10/20.
//  Copyright © 2016年 eme. All rights reserved.
//
/*
 owner:cy
 update:2016年10月20日11:07:30
 info: 首页 轮播图的cell
 VC :  HomePageVc
 */
import UIKit
import RxSwift
import CommonCore

class CyclePictureCCell: UICollectionViewCell,CyclePictureViewDelegate {


    @IBOutlet weak var content_Cpv: CyclePictureView!
    
    var cpImageItem:[CpImageModel]?{
        didSet{

            if let list = self.cpImageItem {
                 self.content_Cpv.imageURLArray = list.map{$0.imsrc}
            }
        }
    }
    
    var didSelectItem_Closure:((_ item:CpImageModel) -> Void)?
    override func awakeFromNib() {
        content_Cpv.imageURLArray = []
        content_Cpv.placeholderImage = UIImage(named: "banner-placeholder")
        content_Cpv.delegate = self
        content_Cpv.timeInterval = 5
        content_Cpv.pageControlAliment = .CenterBottom
        content_Cpv.currentDotColor = UIColor(hex: "ffffff" ,alpha: 0.5)
        content_Cpv.otherDotColor = UIColor(hex: "ffffff")
        
        content_Cpv.detailLableBackgroundColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.5)
    }
    
    func cyclePictureView(cyclePictureView: CyclePictureView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        if let list = self.cpImageItem {
            if list.count > indexPath.row {
                if let didSelectItem_Closure = self.didSelectItem_Closure  {
                    didSelectItem_Closure(list[indexPath.row])
                }
            }
        }
    }
}
